#!/bin/bash
if [ ! -d "/usr/local" ];then
    mkdir /usr/local
fi
cd /usr/local
wget https://repo.huaweicloud.com/nodejs/v14.15.1/node-v14.15.1-linux-x64.tar.xz
tar -xvf node-v14.15.1-linux-x64.tar.xz
rm -f node-v14.15.1-linux-x64.tar.xz
mv /usr/local/node-v14.15.1-linux-x64 /usr/local/node

cd /usr/local/node/bin/
echo "export PATH=$PATH:/usr/local/node/bin" >>/etc/profile
source /etc/profile
ln -s /usr/local/node/bin/node /usr/local/bin/
ln -s /usr/local/node/bin/npm /usr/local/bin/
npm install hexo-cli -g
ln -s /usr/local/node/bin/hexo /usr/local/bin/

mkdir /data
cd /data

hexo init my_hexo_blog
cd /data/my_hexo_blog
npm install
hexo server